package com.gao.thread;

import java.util.concurrent.*;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class ThreadPool {
    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                2,
                5,
                60,
                TimeUnit.MICROSECONDS,
                new ArrayBlockingQueue<>(10),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()

        );
        for (int i = 0; i < 15; i++) {
            executor.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+"执行了任务");
                }
            });
        }

    }
}
